Index: includes/common.inc
===================================================================
--- includes/common.inc	(revision 1104)
+++ includes/common.inc	(working copy)
@@ -3453,7 +3453,13 @@
     $update = array($update);
   }
 
+  // cocomore: drupal_get_schema() needs to access the cache on the default database.
+  //           now it's possible to run drupal_write_record() for different connections
+  $db = db_set_active();
   $schema = drupal_get_schema($table);
+  if ($db) {
+    db_set_active($db);
+  }
   if (empty($schema)) {
     return FALSE;
   }
